AS=/usr/local/mips-cross/bin/mipsel-elf-as
CC=/usr/local/mips-cross/bin/mipsel-elf-gcc
LD=/usr/local/mips-cross/bin/mipsel-elf-ld
OBJCOPY=/usr/local/mips-cross/bin/mipsel-elf-objcopy
OBJDUMP=/usr/local/mips-cross/bin/mipsel-elf-objdump

CFLAGS=-mips1 -fomit-frame-pointer -nodefaultlibs -nostartfiles -nostdlib -membedded-data -mno-mips16 -fno-builtin -g --std=c99 -DTIMES -DHZ=40000000

INCLUDE=-I../../include/

all:
	$(CC) dhrystone.c -c $(CFLAGS) $(INCLUDE) -o dhrystone.o
	$(CC) dhry_1.c -c $(CFLAGS) $(INCLUDE) -o dhry_1.o
	$(CC) dhry_2.c -c $(CFLAGS) $(INCLUDE) -o dhry_2.o
	$(AS) -mips1 bootloader.S -o bootloader.o -EL -g
	$(LD) -mips1 -T ../../lib/default.ld dhrystone.o bootloader.o dhry_1.o dhry_2.o -o dhrystone.elf -EL -g
	$(OBJCOPY) -j .startup.bootvec -j .startup -j .rodata -O binary dhrystone.elf dhrystone.bin
	hexdump -e "1/4 \"%08x\n\"" dhrystone.bin -v > dhrystone.hex

dump:
	$(OBJDUMP) -j .startup.bootvec -j .startup -S -D dhrystone.elf -z

symbols:
	$(OBJDUMP) -t dhrystone.elf

sections:
	$(OBJDUMP) -h dhrystone.elf

clean:
	rm -f dhrystone.bin dhrystone.elf dhrystone.hex dhrystone.o bootloader.o
